Skip to content

fix: score a tenhou the same whichever dealt tile is the win tile - #360

Closed
Nihisil wants to merge 2 commits into
masterfrom
fix/tenhou-win-tile
Closed

Nihisil wants to merge 2 commits into
masterfrom
fix/tenhou-win-tile

Conversation

@Nihisil

@Nihisil Nihisil commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

A tenhou has no winning tile, but kokushi, chuuren and suuankou were judged by the wait of win_tile, so the same dealt hand scored a different yakuman count depending on which tile was passed.

Every tile kind in a tenhou hand is now tried as the winning tile and the most expensive reading is kept. On equal totals the reading with more double yakuman forms wins, so without has_double_yakuman a tenhou still names that form at single yakuman. Chiihou keeps the wait of its drawn tile.

A tenhou has no winning tile, but kokushi, chuuren and suuankou were
judged by the wait of win_tile, so the same dealt hand scored a
different yakuman count depending on which tile was passed.

Every tile kind in a tenhou hand is now tried as the winning tile and
the most expensive reading is kept. On equal totals the reading with
more double yakuman forms wins, so without has_double_yakuman a tenhou
still names that form at single yakuman. Chiihou keeps the wait of its
drawn tile.
@Nihisil
Nihisil requested a review from Apricot-S as a code owner November 18, 2026 02:32
@Nihisil Nihisil added the bug label Nov 18, 2026
Comment thread CHANGELOG.md
Comment on lines +13 to +14
## Bug fixes
- A tenhou with kokushi, chuuren poutou or suuankou scored differently depending on `win_tile`. Now it always scores the thirteen-sided, nine-sided or tanki form.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change should be treated as a behavioral change, not a bug fix.
It might even be considered a breaking change.

Comment on lines +156 to +157
A tenhou has no winning tile, so each tile kind in it is tried as one, and ``win_tile``
does not change the result.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d suggest revising the sentence “A tenhou has no winning tile.” There are two separate rule questions here. Does the game distinguish the dealer’s first draw from the initial deal?
And when the dealer wins with tenhou, does a qualifying hand receive the double-yakuman form regardless of which tile was drawn?

In Mahjong Soul, the game log records all 14 tiles as the dealer’s initial hand. The client displays the last tile in the sorted hand as the drawn tile, but the log does not identify a separate first draw.
Tenhou and Riichi City, on the other hand, both record a 13-tile initial hand followed by a distinct first draw.
Example Tenhou replay

Mahjong Soul and Riichi City both explicitly award the double-yakuman form on tenhou regardless of the drawn tile. I’d describe that scoring rule directly in the docstring. It explains the change and covers both ways of recording the deal.

Tenhou’s rules do not specify how it handles this case. Since Tenhou does not award double yakuman, the score would be the same either way, but the yaku name shown in the result could still differ. Do you have a Tenhou replay where the dealer wins with tenhou and the actual first draw would ordinarily give the single-yakuman form? That would let us check which yaku name Tenhou reports.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I have missed these key details. I will close PR for now and will investigate later how tenhou handles it vs other servers

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I support this change, as it improves compatibility with Mahjong Soul and Riichi City. However, I'm concerned about the compatibility of this library with Tenhou, which it's been testing.

@Nihisil Nihisil closed this Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants